home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / MoreFiles 1.2.1 / FSpCompat.p < prev    next >
Encoding:
Text File  |  1994-07-22  |  9.7 KB  |  259 lines  |  [TEXT/PJMM]

  1. UNIT FSpCompat;
  2.  
  3. {    Apple Macintosh Developer Technical Support                                }
  4. {                                                                            }
  5. {    FSSpec compatibility functions                                            }
  6. {                                                                            }
  7. {    by Jim Luther, Apple Developer Technical Support                        }
  8. {                                                                            }
  9. {    File:        FSpCompat.p                                                    }
  10. {                                                                            }
  11. {    Copyright © 1992-1994 Apple Computer, Inc.                                }
  12. {    All rights reserved.                                                    }
  13. {                                                                            }
  14. {    You may incorporate this sample code into your applications without        }
  15. {    restriction, though the sample code has been provided "AS IS" and the    }
  16. {    responsibility for its operation is 100% yours.  However, what you are    }
  17. {    not permitted to do is to redistribute the source as "DSC Sample Code"    }
  18. {    after having made changes. If you're going to re-distribute the source,    }
  19. {    we require that you make it clear in the source that the code was        }
  20. {    descended from Apple Sample Code, but that you've made changes.            }
  21.  
  22.  
  23. INTERFACE
  24.  
  25.  
  26. {***************************************************************************}
  27.  
  28.  
  29.     FUNCTION FSMakeFSSpecCompat (vRefNum: INTEGER;
  30.                                     dirID: LONGINT;
  31.                                     fileName: Str255;
  32.                                     VAR spec: FSSpec): OSErr;
  33. {    The FSMakeFSSpecCompat function fills in the fields of an FSSpec        }
  34. {    record. If the file system can't create the FSSpec, then the            }
  35. {    compatibility code creates a FSSpec that is exactly like an FSSpec        }
  36. {    except that spec.name for a file may not have the same capitalization    }
  37. {    as the file's catalog entry on the disk volume. That is because            }
  38. {    fileName is parsed to get the name instead of getting the name back        }
  39. {    from the file system. This works fine with System 6 where FSMakeSpec    }
  40. {    isn't available.                                                        }
  41. {                                                                            }
  42. {    vRefNum        input:    Volume specification.                                }
  43. {    dirID        input:    Directory ID.                                        }
  44. {    fileName    input:    Pointer to object name, or nil when dirID specifies    }
  45. {                        a directory that's the object.                        }
  46. {    spec        output:    A file system specification to be filled in by        }
  47. {                        FSMakeFSSpecCompat.                                    }
  48.  
  49.  
  50. {***************************************************************************}
  51.  
  52.  
  53.     FUNCTION FSpOpenDFCompat (spec: FSSpec;
  54.                                     permission: SignedByte;
  55.                                     VAR refNum: INTEGER): OSErr;
  56. {    The FSpOpenDFCompat function opens the data fork of the file specified    }
  57. {    by spec.                                                                }
  58. {    Differences from FSpOpenDF: If FSpOpenDF isn't available,                }
  59. {    FSpOpenDFCompat uses PHBOpen because System 6 doesn't support            }
  60. {    PBHOpenDF. This means FSpOpenDFCompat could accidentally open a driver    }
  61. {    if the spec->name begins with a period.                                    }
  62. {                                                                            }
  63. {    spec        input:    An FSSpec record specifying the file whose data        }
  64. {                        fork is to be opened.                                }
  65. {    permission    input:    A constant indicating the desired file access        }
  66. {                        permissions.                                        }
  67. {    refNum        output:    A reference number of an access path to the file's    }
  68. {                        data fork.                                            }
  69.  
  70.  
  71. {***************************************************************************}
  72.  
  73.  
  74.     FUNCTION FSpOpenRFCompat (spec: FSSpec;
  75.                                     permission: SignedByte;
  76.                                     VAR refNum: INTEGER): OSErr;
  77. {    The FSpOpenRFCompat function opens the resource fork of the file        }
  78. {    specified by spec.                                                        }
  79. {                                                                            }
  80. {    spec        input:    An FSSpec record specifying the file whose resource    }
  81. {                        fork is to be opened.                                }
  82. {    permission    input:    A constant indicating the desired file access        }
  83. {                        permissions.                                        }
  84. {    refNum        output:    A reference number of an access path to the file's    }
  85. {                        resource fork.                                        }
  86.  
  87.  
  88. {***************************************************************************}
  89.  
  90.  
  91.     FUNCTION FSpCreateCompat (spec: FSSpec;
  92.                                     creator: OSType;
  93.                                     fileType: OSType;
  94.                                     scriptTag: ScriptCode): OSErr;
  95. {    The FSpCreateCompat function creates a new file with the specified        }
  96. {    type, creator, and script code.                                            }
  97. {    Differences from FSpCreate: FSpCreateCompat correctly sets the            }
  98. {    fdScript in the file's FXInfo record to scriptTag if the problem        }
  99. {    isn't fixed in the File Manager code.                                    }
  100. {                                                                            }
  101. {    spec        input:    An FSSpec record specifying the file to create.        }
  102. {    creator        input:    The creator of the new file.                        }
  103. {    fileType    input    The file type of the new file.                        }
  104. {    scriptCode    input:    The code of the script system in which the file        }
  105. {                        name is to be displayed.                            }
  106.  
  107.  
  108. {***************************************************************************}
  109.  
  110.  
  111.     FUNCTION FSpDirCreateCompat (spec: FSSpec;
  112.                                     scriptTag: ScriptCode;
  113.                                     VAR createdDirID: LONGINT): OSErr;
  114. {    The FSpDirCreateCompat function creates a new directory and returns        }
  115. {    the directory ID of the newDirectory.                                    }
  116. {                                                                            }
  117. {    spec            input:    An FSSpec record specifying the directory to    }
  118. {                            create.                                            }
  119. {    scriptCode        input:    The code of the script system in which the        }
  120. {                            directory name is to be displayed.                }
  121. {    createdDirID    output:    The directory ID of the directory that was        }
  122. {                            created.                                        }
  123.  
  124.  
  125. {***************************************************************************}
  126.  
  127.  
  128.     FUNCTION FSpDeleteCompat (spec: FSSpec): OSErr;
  129. {    The FSpDeleteCompat function deletes a file or directory.                }
  130. {                                                                            }
  131. {    spec            input:    An FSSpec record specifying the file or         }
  132. {                            directory to delete.                            }
  133.  
  134.  
  135. {***************************************************************************}
  136.  
  137.  
  138.     FUNCTION FSpGetFInfoCompat (spec: FSSpec;
  139.                                     VAR fndrInfo: FInfo): OSErr;
  140. {    The FSpGetFInfoCompat function gets the finder information for a file.    }
  141. {                                                                            }
  142. {    spec        input:    An FSSpec record specifying the file.                }
  143. {    fndrInfo    output:    If the object is a file, then its FInfo.            }
  144.  
  145.  
  146. {***************************************************************************}
  147.  
  148.  
  149.     FUNCTION FSpSetFInfoCompat (spec: FSSpec;
  150.                                     fndrInfo: FInfo): OSErr;
  151. {    The FSpSetFInfoCompat function sets the finder information for a file.    }
  152. {                                                                            }
  153. {    spec        input:    An FSSpec record specifying the file.                }
  154. {    fndrInfo    input:    The FInfo.                                            }
  155.  
  156.  
  157. {***************************************************************************}
  158.  
  159.  
  160.     FUNCTION FSpSetFLockCompat (spec: FSSpec): OSErr;
  161. {    The FSpSetFLockCompat function locks a file.                            }
  162. {                                                                            }
  163. {    spec        input:    An FSSpec record specifying the file.                }
  164.  
  165.  
  166. {***************************************************************************}
  167.  
  168.  
  169.     FUNCTION FSpRstFLockCompat (spec: FSSpec): OSErr;
  170. {    The FSpRstFLockCompat function unlocks a file.                            }
  171. {                                                                            }
  172. {    spec        input:    An FSSpec record specifying the file.                }
  173.  
  174.  
  175. {***************************************************************************}
  176.  
  177.  
  178.     FUNCTION FSpRenameCompat (spec: FSSpec;
  179.                                     newName: Str255): OSErr;
  180. {    The FSpRenameCompat function renames a file or directory.                }
  181. {                                                                            }
  182. {    spec        input:    An FSSpec record specifying the file.                }
  183. {    newName        input:    The new name of the file or directory.                }
  184.  
  185.  
  186. {***************************************************************************}
  187.  
  188.  
  189.     FUNCTION FSpCatMoveCompat (source: FSSpec;
  190.                                     dest: FSSpec): OSErr;
  191. {    The FSpCatMoveCompat function moves a file or directory to a different    }
  192. {    location on on the same volume.                                            }
  193. {                                                                            }
  194. {    source        input:    An FSSpec record specifying the file or directory.    }
  195. {    dest        input:    An FSSpec record specifying the name and location    }
  196. {                        of the directory into which the source file or        }
  197. {                        directory is to be moved.                            }
  198.  
  199.  
  200. {***************************************************************************}
  201.  
  202.  
  203.     FUNCTION FSpExchangeFilesCompat (source: FSSpec;
  204.                                     dest: FSSpec): OSErr;
  205. {    The FSpExchangeFilesCompat function swaps the data in two files by        }
  206. {    changing the information in the volume's catalog and, if the files        }
  207. {    are open, in the file control blocks.                                    }
  208. {    Differences from FSpExchangeFiles: Correctly exchanges files on volumes    }
  209. {    that don't support PBExchangeFiles. FSpExchangeFiles attempts to        }
  210. {    support volumes that don't support PBExchangeFiles, but in System 7,    }
  211. {    7.0.1, 7.1, and 7 Pro, the compatibility code just doesn't work on        }
  212. {    volumes that don't support PBExchangeFiles (even though you may get a    }
  213. {    noErr result). System Update 3.0 and System 7.5 and later have the        }
  214. {    problems in FSpExchangeFiles corrected.                                    }
  215.  
  216.  
  217. {***************************************************************************}
  218.  
  219.  
  220.     FUNCTION FSpOpenResFileCompat (spec: FSSpec;
  221.                                     permission: SignedByte): INTEGER;
  222. {    The FSpOpenResFileCompat function opens the resource file specified        }
  223. {    by spec.                                                                }
  224. {                                                                            }
  225. {    spec            input:    An FSSpec record specifying the file whose        }
  226. {                            resource file is to be opened.                    }
  227. {    permission        input:    A constant indicating the desired file access    }
  228. {                            permissions.                                    }
  229. {    function result    output:    A resource file reference number, or if there's    }
  230. {                            an error -1.                                    }
  231.  
  232.  
  233. {***************************************************************************}
  234.  
  235.  
  236.     PROCEDURE FSpCreateResFileCompat (spec: FSSpec;
  237.                                     creator: OSType;
  238.                                     fileType: OSType;
  239.                                     scriptTag: ScriptCode);
  240. {    The FSpCreateResFileCompat function creates a new resource file with    }
  241. {    the specified type, creator, and script code.                            }
  242. {    Differences from FSpCreateResFile: FSpCreateResFileCompat correctly        }
  243. {    sets the fdScript in the file's FXInfo record to scriptTag if the        }
  244. {    problem isn't fixed in the File Manager code.                            }
  245. {                                                                            }
  246. {    spec        input:    An FSSpec record specifying the resource file to    }
  247. {                        create.                                                }
  248. {    creator        input:    The creator of the new file.                        }
  249. {    fileType    input    The file type of the new file.                        }
  250. {    scriptCode    input:    The code of the script system in which the file        }
  251. {                        name is to be displayed.                            }
  252.  
  253.  
  254. {***************************************************************************}
  255.  
  256.  
  257. IMPLEMENTATION
  258.  
  259. END.